package com.primary.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.primary.controller.request.DonationcarsReqeust;
import com.primary.entity.Donationcars;
import com.primary.mappers.DonationcarsMapper;
import com.primary.service.DonationcarsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("DonationcarsService")
public class DonationcarsServiceImpl implements DonationcarsService {

    @Autowired
    DonationcarsMapper donationcarsMapper;
    /**
     * 用于分页显示信息
     *
     * @param donationcarsReqeust
     */
    @Override
    public PageInfo<Map<String, Object>> queryByPage(DonationcarsReqeust donationcarsReqeust) {
        PageHelper.startPage(donationcarsReqeust.getPageNum(), donationcarsReqeust.getPageSize());
        return new PageInfo<>(donationcarsMapper.listByPage(donationcarsReqeust));
    }

    /**
     * 插入一条数据
     *
     * @param donationcars
     * @return
     */
    @Override
    public int insertOne(Donationcars donationcars) {
        return donationcarsMapper.insertOne(donationcars);
    }

    /**
     * 更新一条数据
     *
     * @param donationcars
     * @return
     */
    @Override
    public int updateOneById(Donationcars donationcars) {
        return donationcarsMapper.updateOneById(donationcars);
    }

    /**
     * 删除一条记录
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Integer id) {
        return donationcarsMapper.deleteById(id) > 0;
    }
}
